from itsdangerous import  TimedJSONWebSignatureSerializer
from meiduo_mall import settings
def generic_email_verify_token(user_id):
    #1.创建实例
    s = TimedJSONWebSignatureSerializer(settings.SECRET_KEY,expires_in=3600)
    #2.加密数据
    data = s.dumps({'user_id':user_id})
    return data.decode()
def check_verify_token(token):
    #1.创建实例
    s = TimedJSONWebSignatureSerializer(settings.SECRET_KEY,expires_in=3600)
    #2.解密数据
    try:
        data = s.loads(token)
    except:
        return None
    else:
        return data.get('user_id')